<template>
	<view class="success">
		<text><text style="font-size: 24px;">✔</text>支付成功</text>
		<text>{{count}}s后跳转首页</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time:null,
				count:3,
			}
		},
		methods: {
			toIndex(){
				this.time=setInterval(()=>{
					// console.log("3秒后跳转首页")
					this.count--
					if(this.count==0){
						uni.switchTab({
							url:'../../pages/index/index'
						})
					}
					// console.log("跳转成功")
				},1000)
				
			}
		},
		onLoad() {
			this.toIndex()
		},
		onUnload(){
			if(this.timer) {  
					clearInterval(this.timer);  
					this.timer = null;  
				} 
		}
	}
</script>

<style scoped lang="scss">
	.success{
		color: #18BC37;
		font-size: 18px;
		padding-top: 150px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
</style>
